package 设计模式.Test.test01;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * @Author: kirito
 * @Date: 2024/4/3 13:09
 * @Description:
 */

@Component
public class BusinessChainFactory {
    @Autowired
    @Qualifier("firstBusinessChain")
    private BusinessChain firstBusinessChain;

    @Autowired
    @Qualifier("secondBusinessChain")
    private BusinessChain secondBusinessChain;

    @Autowired
    @Qualifier("thirdBusinessChain")
    private BusinessChain thirdBusinessChain;

    @PostConstruct
    public void init() {
        firstBusinessChain.setNext(secondBusinessChain);
        secondBusinessChain.setNext(thirdBusinessChain);
        thirdBusinessChain.setNext(null);

    }

    public BusinessChain businessChain() {
        return firstBusinessChain;
    }
}
